using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Afrs.Draco.Prms.Client.Proxy;
using Afrs.Prms.DataObject;

namespace 
{
  /// <summary>
  /// Divisions Test Class
  /// </summary>
  [TestClass]
  public class TestDivisions
  {
    #region Class Variables
    private CdoPrms<DODivisions>		m_Divisions;
    private CdoPrmsList<DODivisions>	m_AllDivisions;
    #endregion

    #region Class Constructors & Destructors
    /// <summary>
    /// Constructs the test
    /// </summary>
    public TestDivisions()
    {
      // Create the data objects
      this.m_Divisions	= new CdoPrms<DODivisions>();
      this.m_AllDivisions	= new CdoPrmsList<DODivisions>();
    }
    #endregion

    #region Class Methods
    /// <summary>
    /// Retrieves all Divisions data objects
    /// </summary>
    [TestMethod]
    public void DivisionsRetrieveAll()
    {
      // Set up the data object for list retrieval
      this.m_AllDivisions.DataObject = new DODivisions();
      this.m_AllDivisions.ListAction = AfrsDOListAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_AllDivisions.PerformAction())
      {
        // Assert the errors
        if (this.m_AllDivisions.Errors.Count > 0) { Assert.Fail(this.m_AllDivisions.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Create a new Divisions
    /// </summary>
    [TestMethod]
    public void DivisionsCreate()
    {
      // Set up the data object for creation
      this.m_Divisions.DataObject.Action = AfrsDataObjectAction.Create;

      // Perform the action and determine the success
      if (!this.m_Divisions.PerformAction())
      {
        // Assert the errors
        if (this.m_Divisions.Errors.Count > 0) { Assert.Fail(this.m_Divisions.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Retrieves a specific Divisions
    /// </summary>
    [TestMethod]
    public void DivisionsRetrieve()
    {
      // Determine whether the data object needs to be specified
      if (this.m_Divisions.DataObject.Id == 0)
      {
        // Specify the data object to retrieve
        this.m_Divisions.DataObject.DivisionName = "Test DivisionName";
      }

      // Set up the data object action for retrieval
      this.m_Divisions.DataObject.Action = AfrsDataObjectAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_Divisions.PerformAction())
      {
        // Assert the errors
        if (this.m_Divisions.Errors.Count > 0) { Assert.Fail(this.m_Divisions.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }
    #endregion
  }
}
